package com.atguigu.gulimall.test.service.impl;

import com.atguigu.gulimall.test.entity.Student;
import com.atguigu.gulimall.test.service.TService;

import java.util.ArrayList;
import java.util.List;

public class StudentServiceImpl implements TService<Student> {

    private List<Student> list = new ArrayList<>();

    @Override
    public void add(Student student) {
        this.list.add(student);
    }

    @Override
    public Student get(Student stu) {
        for (Student student : list) {
            if(stu.getId().toString().equals(student.getId().toString())){
                return student;
            }
        }
        return null;
    }

    @Override
    public void update(Student stu) {
        for (Student student : list) {
            if(student.getId().toString().equals(stu.getId().toString())){
                student.setName(stu.getName());
            }
        }
    }
}
